package org.zfes.snowier.zbss.xzy.router.solution;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.zbss.xzy.biz.solution.model.Solution;
import org.zfes.snowier.zbss.xzy.biz.solution.service.ISolutionAlgorithmService;
import org.zfes.snowier.zbss.xzy.biz.solution.service.ISolutionService;
import org.zfes.snowier.zbss.xzy.solution.SolutionAlgorithmSetDto;
import org.zfes.snowier.core.data.SelectVo;
@Controller 
@RequestMapping("/manager/solution")
public class SolutionController implements BaseController {

	
	@Autowired
	private ISolutionService solutionService;
	@Autowired
	private ISolutionAlgorithmService solutionAlgorithmService;
	//@RequiresPermissions(value="solution:loadSolutionDataSet",desc="解决方案列表")
    @RequestMapping(value="/loadSolutionDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadSolutionDataSet(@RequestBody Map<String,Object> params){
	    DataSet dataSet=  solutionService.loadSolutionDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	//@RequiresPermissions(value="solution:createSolution",desc="解决方案添加")
    @RequestMapping(value="/createSolution", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public  @ResponseBody Object createSolution(@RequestBody Solution solution){
		solutionService.createSolution(solution);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="solution:loadSolution",desc="解决方案加载")
    @RequestMapping(value="/loadSolution/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadSolution(@PathVariable("id")Long id){
		Optional<Solution> ops = solutionService.loadSolutionById(id);
		return ajaxQuery("solution",ops);
    }
	
	//@RequiresPermissions(value="solution:updateSolution",desc="解决方案更新")
    @RequestMapping(value="/updateSolution", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object updateSolution(@RequestBody  Solution solution){
		solutionService.updateSolution(solution);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="solution:deletSolution",desc="解决方案删除")
    @RequestMapping(value="/deleteSolution/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object deleteSolution(@PathVariable("id")Long id){
		solutionService.deleteSolution(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

    @RequestMapping(value="/setSolutionStatus", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object setSolutionStatus(Long id,Byte status){
		solutionService.setSolutionStatus(id, status);
		return ajaxDoneSuccess("数据操作成功 ");
    }


    @RequestMapping(value="/loadSolutionSelectVo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadSolutionSelectVo(){
		 List<SelectVo>  ops = solutionService.loadSolutionSelectVo("");
		return ajaxQuery("selectVo",ops);
    }
    
  
    
    
    
}